package cn.wolfcode.luowowo.service.impl;

import cn.wolfcode.luowowo.article.domain.Scenicspot;
import cn.wolfcode.luowowo.article.mapper.ScenicspotMapper;
import cn.wolfcode.luowowo.article.service.IScenicspotService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ScenicspotServiceImpl implements IScenicspotService {
    @Autowired
    private ScenicspotMapper scenicspotMapper;

    public List<Scenicspot> getTop5() {
        List<Scenicspot> scenicspots = scenicspotMapper.selectTop5();
        for (Scenicspot scenicspot : scenicspots) {
            scenicspot.setInsideScenicspots(scenicspotMapper.selectInsideScenicspots(scenicspot.getScenicspotIds()));
        }
        return scenicspots;
    }

    public List<Scenicspot> getInsideScenicspots(Long id) {
        Scenicspot scenicspot = scenicspotMapper.selectByPrimaryKey(id);
        return scenicspotMapper.selectInsideScenicspots(scenicspot.getScenicspotIds());
    }

    public List<Scenicspot> getHotScenic() {
        return scenicspotMapper.selectHotScenic().subList(5,15);
    }

    public List<Scenicspot> list() {
        return scenicspotMapper.selectAll();
    }

    public List<String> getCatalogs() {
        return scenicspotMapper.selectCatalogs();
    }

    public Scenicspot get(Long id) {
        Scenicspot scenicspot = scenicspotMapper.selectByPrimaryKey(id);
        scenicspot.setInsideScenicspots(scenicspotMapper.selectInsideScenicspots(scenicspot.getScenicspotIds()));
        return scenicspot;
    }

    @Override
    public List<Scenicspot> getTop3() {
        return scenicspotMapper.selectTop3();
    }
}
